package com.songlanyun.modules.ad.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.songlanyun.common.drive.RootEntity;
import com.songlanyun.common.validator.group.AddGroup;
import com.songlanyun.common.validator.group.UpdateGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 广告表
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-11 13:55:19
 */
@Data
@TableName("yxt_ad")
public class AdEntity extends RootEntity<Integer, AdEntity> implements Serializable {
    private static final long serialVersionUID = 1L;

    {
        isTop = false;
        topTime = new Date();
    }

    /**
     *
     */
    @TableId
    private Integer id;
    /**
     * 广告位标识码（用来做前段输出）
     */
    @NotBlank(message = "广告位标识码不能为空")
    private String markCode;
    /**
     * 标题
     */
    @NotBlank(message = "标题不能为空")
    @Length(min = 1, max = 16, message = "标题长度在1-16个字")
    private String title;
    /**
     * 图片
     */
    @NotBlank(message = "图片不能为空")
    private String cover;
    /**
     * 'opus' 作品，
     * ‘news’ 文章，
     * ‘goods’ 商品，
     * ‘service’ 服务，
     * ‘url’ 链接
     * ‘point_goods’ 积分商品，
     * ‘inner_url’ 内部链接
     */
    @NotBlank(message = "广告类型不能为空")
    private String modelType;
    /**
     *
     */
    private Long modelId;

    private String url;
    /**
     * 备注
     */
    @NotBlank(message = "备注不能为空")
    @Length(min = 1, max = 500, message = "标题长度在1-500个字")
    private String remark;

    /**
     * 商家id
     */
    private Long shopId;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;
    /**
     *
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;


    /**
     * 上下线
     */
    @NotNull(message = "上下线不能为空")
    private Boolean onOff;

    /**
     * 是否置顶 1：置顶
     */
    private Boolean isTop;
    /**
     * 置顶时间
     */
    private Date topTime;
    /**
     * 排序号
     */
    @NotNull(message = "排序号不能为空")
    private int sort;

    @TableField(exist = false)
    private AdLocationEntity adLocationEntity;

    /**
     * 广告位名称
     */
    @TableField(exist = false)
    private String adLocationName;


    @Override
    public Integer getIdentity() {
        return id;
    }
}
